package com.mianyang.zhangsan.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mianyang.zhangsan.common.base.BaseController;
import com.mianyang.zhangsan.common.base.R;
import com.mianyang.zhangsan.model.entity.SecVideo;
import com.mianyang.zhangsan.model.entity.SecVideoTask;
import com.mianyang.zhangsan.service.SecVideoTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jiangjr
 */
@RestController
@RequestMapping("/task")
public class SecVideoTaskController extends BaseController {
    @Autowired
    private SecVideoTaskService videoTaskService;

    /**
     * 查看自己的学习任务
     */
    @GetMapping("/self")
    public R selfVideo() {
        List<SecVideo> videos = videoTaskService.selectTaskVideos();
        return success("videos", videos);
    }

    /**
     *
     * 查看某人的学习情况
     */
    @GetMapping("/other")
    public R taskVideo(Long accountId,
                       @RequestParam(value = "current", defaultValue = "1") int current,
                       @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        Page<SecVideoTask> videos = videoTaskService.selectTaskByAccountId(accountId, current, pageSize);
        return success("videos", videos);
    }

    /**
     * 为用户指定学习任务（管理员权限）
     */
    @PostMapping("/arrange")
    public R arrangementTask() {

        return success();
    }
}
